package com.fort.teachermanagementsys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fort.teachermanagementsys.entity.Course;
import com.fort.teachermanagementsys.mapper.CourseMapper;
import com.fort.teachermanagementsys.service.CourseService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {
    @Override
    public List<Course> getAllCourses() {
        return list();
    }


    @Override
    public Course addCourse(Course course) {
        // Set creation and update timestamps
        LocalDateTime now = LocalDateTime.now();
        course.setCreatedAt(now);
        course.setUpdatedAt(now);

        // Save course to database
        baseMapper.insert(course);
        return course;
    }
}
